<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/2/3
 * Time: 10:14
 */
namespace common\models;

use Yii;
use yii\db\ActiveRecord;

class Goods extends ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%goods}}';
    }

    public static function findByGoodsSn($goods_sn, $status = 1)
    {
        return static::find()->where(['sn' => $goods_sn, 'status' => $status])->one();
    }

    // 取得首页显示海带的8个产品
    public static function findIndexGoods($arr_goods)
    {
        return static::find()->where(['id' => $arr_goods])->orderBy('sn')->all();
    }

    public static function getGoods($id)
    {
        return static::find()->where(['id' => $id])->asArray()->one();
    }
}